<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>

<script language="javascript" type="text/javascript">

function check()
{
	var c1,c2,c3,c4,c41,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15;
	
  	
        
        
        c3= document.f1.pan.value;
        if(c3.length == 0)
        {
             alert("Please Enter PAN Number");
           
             document.f1.pan.focus();
             return false;
        }
        
        var PAN_REGEX= "^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}$";
        
        if(!c3.match(PAN_REGEX))
        {
       	 alert("Please Enter PAN Number in right format. For ex- AAAA1111A");
       	document.f1.pan.value="";
        document.f1.pan.focus();
       	 return false;
        }
        
        var re=/^\d{4}\/\d{1,2}\/\d{1,2}$/; 
        c5=document.f1.dob.value.match(re);
        if(document.f1.dob.value == '')
        {
        	alert("Enter a Date");
        	
           document.f1.dob.focus();
            return false;
      	 }
        if (! document.f1.dob.value.match(re))
        {
            alert("Enter a valid date.");
            document.f1.dob.value = "";
            document.f1.dob.focus();
            return false;
        }
        
        c4= document.f1.pass.value;
        c41= document.f1.cpass.value;
        if(c4.length==0)
        {
        	alert("Enter password");
        	
           document.f1.pass.focus();
            return false;
      	 }
        if(c41.length==0)
        {
        	alert("Enter password to confirm");
        	
           document.f1.cpass.focus();
            return false;
      	 }
        
        if(c4!=c41)
        {
			alert("Password mismatch... Enter password again");
			document.f1.cpass.value="";
            document.f1.cpass.focus();
             return false;
        	
        }
        
       
        
          /*  var regExp1 = /^(\d{1,2})\/(\d{1,2})\/(\d{2})$/;
            var regExp2 = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
            var result1 = document.f1.dob.value.match(regExp1);
            var result2 = document.f1.dob.value.match(regExp2);
            
            if (result1 == null && result2 == null)
            {
                alert("Enter a valid date.");
                document.f1.dob.value = "";
                document.f1.dob.focus();
                return false;
            }*/
        
          
          c14= document.f1.email.value;
          
          var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
          
         
          if(c14.length == 0)
          {
              alert("Please Enter Email address");
              
              document.f1.email.focus();
              return false;
          }
          if(regex.test(c14) == false)
          {
               alert("Invalid Email Address");
               document.f1.email.value="";
               document.f1.email.focus();
               return false;
           }
          
          c15= document.f1.phone.value;
          if(c15.length == 0)
          {
              alert("Please Enter Phone Number");
              
              document.f1.phone.focus();
              return false;
          }
          
          if(c15.indexOf(" ")!=-1)
     	 {
        		alert("Invalid Phone No.");
        		document.f1.phone.value="";
                document.f1.phone.focus();
       		return false;
     	 }
          if(c15.length<10)
       	 {
           	alert("Phone Number should not be less than 10 digit");
           	document.f1.phone.value="";
             document.f1.phone.focus();
         		return false;
       	 }
     	  if(c15.length>10)
      	 {
          	alert("Phone Number should be 10 digit");
          	document.f1.phone.value="";
            document.f1.phone.focus();
        		return false;
      	 }
          return true;
}


    </script>

</head>
<body>
<h2 align="center"> Register with Books of Accounts</h2>
<form name="f1" action="RegisterServlet" ONSUBMIT="return check()">
<table cellspacing=6 align="center">
<tr>
<td>PAN Number <font color=red>*</font></td>
<td><input type="text" name="pan"/></td>
</tr>
<tr>
<td>Date of Birth/Incorporation <font color=red>*</font></td>
<td><input type="text" name="dob"/></td>
<td>(yyyy/mm/dd)</td>
</tr>
<tr>
<td>Enter Password <font color=red>*</font></td>
<td><input type="password" name="pass"/></td>
</tr>
<tr>
<td>Confirm Password <font color=red>*</font></td>
<td><input type="password" name="cpass"/></td>
</tr>
<tr>
<td>Email ID <font color=red>*</font></td>
<td><input type="text" name="email"/></td>
</tr>
<tr>
<td>Mobile Number <font color=red>*</font></td>
<td><input type="text" name="phone"/></td>
</tr>
<tr><td></td>
<td><input type="submit" name="sub" value="Submit"/></td>
</tr>
</table>
<center><a href="Login.jsp">Go to Login Page</a></center>
</form>
</body>
</html>